<!doctype html>
<html>
<head>
<meta charset="utf-8">

<link href="../css/preview.css" rel='stylesheet' type='text/css'>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.min.js"></script>
<script type="text/javascript" src="../tinymce/js/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
    selector: "textarea"
 });
</script>
<?php

include('../php/db.php');

if ($_SESSION['login'] == NULL)
{
 header("Location: ../index.php");	
}
else
{
$login = $_SESSION['login'];

$userid = mysql_query("SELECT * FROM `flss`.`accounts` WHERE `user` = '$login'");
while($rowshow = mysql_fetch_array($userid))
{
	$getid = $rowshow['account_id'];
}
$getcname = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getid' ") or die(mysql_error);
$getrow2 = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getid' ") or die(mysql_error);
$getrow3 = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getid' ") or die(mysql_error);
$getrow4 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getid' ") or die(mysql_error);
$getrow5 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getid' ") or die(mysql_error);
$getrow6 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getid' ") or die(mysql_error);
$getrow7 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getid' ") or die(mysql_error);
$getrow8 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getid' ") or die(mysql_error);
$getrow9 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getid' ") or die(mysql_error);
$getrow10 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getid' ") or die(mysql_error);

$getvariable =  $_GET['refid'];

echo $getvariable;

$gettitle = mysql_query("SELECT * FROM `flss`.`jobs_temp` WHERE `Employer_ID` = '$getid' AND `refid` = '$getvariable' ") or die(mysql_error);
$getcat = mysql_query("SELECT * FROM `flss`.`jobs_temp` WHERE `Employer_ID` = '$getid' AND `refid` = '$getvariable' ") or die(mysql_error);
$getsubcat = mysql_query("SELECT * FROM `flss`.`jobs_temp` WHERE `Employer_ID` = '$getid' AND `refid` = '$getvariable' ") or die(mysql_error);
$getmined = mysql_query("SELECT * FROM `flss`.`jobs_temp` WHERE `Employer_ID` = '$getid' AND `refid` = '$getvariable' ") or die(mysql_error);
$getyoe = mysql_query("SELECT * FROM `flss`.`jobs_temp` WHERE `Employer_ID` = '$getid' AND `refid` = '$getvariable' ") or die(mysql_error);
$getdesc = mysql_query("SELECT * FROM `flss`.`jobs_temp` WHERE `Employer_ID` = '$getid' AND `refid` = '$getvariable' ") or die(mysql_error);
$getreq = mysql_query("SELECT * FROM `flss`.`jobs_temp` WHERE `Employer_ID` = '$getid' AND `refid` = '$getvariable' ") or die(mysql_error);
$getcdate = mysql_query("SELECT * FROM `flss`.`jobs_temp` WHERE `Employer_ID` = '$getid' AND `refid` = '$getvariable' ") or die(mysql_error);
$getapp = mysql_query("SELECT * FROM `flss`.`jobs_temp` WHERE `Employer_ID` = '$getid' AND `refid` = '$getvariable' ") or die(mysql_error);

$gettitle2 = mysql_query("SELECT * FROM `flss`.`jobs_temp` WHERE `Employer_ID` = '$getid' AND `refid` = '$getvariable' ") or die(mysql_error);
$getcname2 = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getid' ") or die(mysql_error);
$getcname3 = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getid' ") or die(mysql_error);

while($employerrowphoto = mysql_fetch_array($getcname3))
{
  $clogo = $employerrowphoto['logo'];
  $ccover = $employerrowphoto['cover'];
}


$logo = empty($clogo) ? DEFAULT_LOGO : IMAGE_URL_SMALL.$clogo; 
$cover = empty($ccover) ? DEFAULT_COVER : IMAGE_URL_SMALL.$ccover;


}

?>

        
        
<title>Preview of <?php  while ($test = mysql_fetch_array($gettitle2)) {
                	echo $test['Jobs_title'];
					echo " @";
					} ?>
                    <?php  while ($test2 = mysql_fetch_array($getcname2)) {
                     echo $test2['ename'];
                   }  ?> 
</title>
       
</head>
<body>
	<div class="h-top">
		<div class="h-top-logo">
			<a href="#"> <img src="../images/handlogo.png" height="50"> </a>
 
		</div>
		<div style="margin-right:400px; float:right;">
			<p><h3> THIS IS ONLY A PREVIEW </h3></p>

		</div>
	</div>
		<div class="b-sub-container">
			<div class="b-content">
    					<div class="b-image-upload">
                        <img id="companyCover" width = "960" height = "250" src="<?=$cover?>"/>
    					
        				</div>
				<div class="b-sub-content">
        				<div class="b-company-logo">
                        <img id="companyLogo" width = "150" height = "150" src="<?=$logo?>"/>
        
						</div>
                                <div class="b-company-name-container">
                                    <div class="b-company-name" >
                                        <div  style="font-size:18px; margin-left:10px;" name="companyname">
                                             <?php  while ($cols1 = mysql_fetch_array($gettitle)) {
                                                                echo $cols1['Jobs_title'];
                                                                echo "<br>";
                                                                $gtitle = $cols1['Jobs_title'];
                                                        }  ?>
                                            <?php  while ($row = mysql_fetch_array($getcname)) {
                                             echo $row['ename'];
                                            }  ?> 
                                        </div> 
                                    </div>
                                </div>
                                <div class="b-company-overview-container">
                                    <div class="b-company-overview">
                                        <div class="b-company-overview-content">
                                            <div  class="b-company-overview-title" name="companyoverview"> Company Overview </div>
                                                <div class="b-company-overview-context" name="companyoverviewcontext"> 
                                                    <?php  while ($row2 = mysql_fetch_array($getrow2)) {
                                                        echo $row2['description'];
                                                    }  ?>
                                                </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="b-company-why-container">
                                    <div class="b-company-why">
                                        <div class="b-company-why-content">
                                            <div class="b-company-why-title" name="companywhy"> Why Join Us </div>
                                                <div class="b-company-why-context" name="companywhycontext">
                                                    <?php  while ($row3 = mysql_fetch_array($getrow3)) {
                                                        echo $row3['whyjoinus'];
                                                    }  ?>
                                                </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="job-description-container">
                                    <div class="job-description">
                                        <div class="job-description-content">
                                            <div class="job-description-title"> Job Description </div>
                                                <div class="job-description-context">
                                                    <?php  while ($cols6 = mysql_fetch_array($getdesc)) {
                                                        echo $cols6['Jobs_Description'];
                                                        $gdesc = $cols6['Jobs_Description'];
                                                    }  ?>
                                                </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="job-requirements-container">
                                    <div class="job-requirements">
                                        <div class="job-requirements-content">
                                            <div class="job-requirements-title"> Job Requirements </div>
                                                <div class="job-requirements-context">
                                                    <?php  while ($cols7 = mysql_fetch_array($getreq)) {
                                                                        echo $cols7['Jobs_Requirements'];
                                                                        $greq = $cols7['Jobs_Requirements'];
                                                                }  ?>
                                                </div>
                                        </div>
                                    </div>
                                </div>
                                                        <!-- <div>
                                                        <?php  while ($cols8 = mysql_fetch_array($getcdate)) {
                                                                                    $cdate = $cols8['Jobs_ClosingDate'];
                                                                            }  ?>
                                                        </div>
                                                        <div>
                                                        <?php  while ($cols9 = mysql_fetch_array($getapp)) {
                                                                                    $cneed = $cols9['Jobs_AppNeeded'];
                                                                            }  ?>
                                                        </div>
                                                        -->
                        </div>
                        
                        <div class="b-company-right">
                            <div class="b-company-snap-container">
                                <div class="b-company-snap">
                                    <div class="b-company-snap-content">
                                        <div  style="font-size:18px; margin-left:10px;" name="companysnap"> Company Snapshot </div>
                                            <div class="tstyle">
                                            <table height="250">
                                            <tr>
                                            <td>Registration No: </td>
                                            <td><?php  while ($row4 = mysql_fetch_array($getrow4)) {
                                             echo $row4['Registration_No'];
                                        }  ?>  </td>
                                            </tr>
                                            <tr>
                                            <td>Industry: </td>
                                            <td><?php  while ($row5 = mysql_fetch_array($getrow5)) {
                                             echo $row5['Industry'];
                                        }  ?>  </td>
                                            </tr>
                                            <tr>
                                            <td>Company Size: </td>
                                            <td><?php  while ($row6 = mysql_fetch_array($getrow6)) {
                                             echo $row6['Company_size'];
                                        }  ?>  </td>
                                            </tr>
                                            <tr>
                                            <td>Working Hours: </td>
                                            <td><?php  while ($row7 = mysql_fetch_array($getrow7)) {
                                             echo $row7['Working_hours'];
                                        }  ?>  </td>
                                            </tr>
                                            <tr>
                                            <td>Dress Code: </td>
                                            <td><?php  while ($row8 = mysql_fetch_array($getrow8)) {
                                             echo $row8['Dresscode'];
                                        }  ?>  </td>
                                            </tr>
                                            <tr>
                                            <td>Benefits </td>
                                            <td><?php  while ($row9 = mysql_fetch_array($getrow9)) {
                                             echo $row9['Benefits'];
                                        }  ?>  </td>
                                            </tr>
                                            <tr>
                                            <td>Spoken Language(s): </td>
                                            <td><?php  while ($row10 = mysql_fetch_array($getrow10)) {
                                             echo $row10['Spoken_language'];
                                        }  ?>  </td>
                                            </tr>
                    
                    
                                            </table>
                                            </div>
                                    </div>
                                </div>
                            </div>
                            
                           <div class="b-job-category-container">
                                <div class="b-job-category">
                                    <div class="b-job-category-content">
                                        <div  style="font-size:18px; margin-left:10px;" name="companycategory"> Job Category</div>
                                            <div class="tstyle">
                                      <table>
                                      <tr>
                                      <td> Main Category: </td>
                                      <td>      
                                        <?php  while ($cols2 = mysql_fetch_array($getcat)) {
                                        $catid = $cols2['Jobs_Category'];
                                            }
                                        $catarray = mysql_query("SELECT * FROM `flss`.`job_category` WHERE `Category_ID` = '$catid'") or die(mysql_error());
                                        while ($catshow = mysql_fetch_array($catarray)){
                                    
                                        echo $catshow['Jobs_Name'];
                                            $gcat = $catshow['Jobs_Name'];
                                            }
                                          ?>
                                     </td>
                                     </tr>
                                     <tr>
                                     <td> Sub Category: </td>
                                     <td>
                                        <?php  while ($cols3 = mysql_fetch_array($getsubcat)) {
                                                    $subcatid =  $cols3['Jobs_Subcategory'];
                                                            }  
                                                            
                                            $subcatarray = mysql_query("SELECT * FROM `flss`.`job_sub` WHERE `Category_ID` = '$catid' AND `sub_no` = '$subcatid'") or die(mysql_error());
                                                    while ($subcatshow = mysql_fetch_array($subcatarray)){
                                                
                                                    echo $subcatshow['sub_job'];
                                                        $gsub =$subcatshow['sub_job'];
                                                        }
                                                      ?>
                                     </td>
                                     </tr>
                                     <tr>       
                                     <td> Minimum Education: </td>
                                     <td>	
                                        <?php  while ($cols4 = mysql_fetch_array($getmined)) {
                                                        $minedid = $cols4['Jobs_MinEd'];
                                                }  
                                                
                                        $minedarray = mysql_query("SELECT * FROM `flss`.`educ_attainment` WHERE `educ_level` = '$minedid'") or die(mysql_error());
                                        while ($minedshow = mysql_fetch_array($minedarray)){
                                    
                                        echo $minedshow['descirption'];
                                        $ged = $minedshow['descirption'];
                                            
                                            }			
                                                ?>
                                    </td>
                                    </tr>
                                    <tr>
                                    <td> Minimum Experience </td>
                                    <td>
                                            <?php  while ($cols5 = mysql_fetch_array($getyoe)) {
                                                                        $yoeid =  $cols5['Jobs_YoE'];
                                                                }  
                                                                
                                                $yoearray = mysql_query("SELECT * FROM `flss`.`year_experienced` WHERE `yr_ID` = '$yoeid'") or die(mysql_error());
                                                        while ($yoeshow = mysql_fetch_array($yoearray)){
                                                    
                                                        echo $yoeshow['ye_level'];
                                                            $gyoe =$yoeshow['ye_level'];
                                                            }
                                                                
                                                                ?>
                                    </td>
                                    </tr>
                                    </table>        			
                                        
                                        </div>
                                    </div>
                                </div>
                            </div>
                           <div class="b-company-map-container">
                                <div class="b-company-map">
                                   <div class="b-company-map-content">
                                    <div  style="font-size:18px; margin-left:10px;" name="companyloc"> Company Location </div>	
                                    <div style="margin-top:10px; margin-left:10px;">
                                  		<?php
										$getmap = mysql_fetch_array(mysql_query("SELECT * FROM e_map WHERE employer_id = '$getid'"));
										echo $getmap['e_address'];
										?>
                                    </div>
                                 </div>
                                </div>
                            </div>
                	</div>	
			</div>
		</div>
		<div class="footerbutton">
              <form action='' method="post">
              	   <input class="button-link" type="submit" name="btnBack" value="BACK">
                   <input class="buttons-link" type="submit" name="btnSave" value="SAVE">
              	
              </form>
        </div>
        <div class="footer">
        	
            <div style="margin-top:20px; float:left; width:100%;">
            <center>
            <p><small> Anything that is on this page will not be edited no more </small> </p>
            
            <p>Copyright @ Famous Labor Supply Service Alright Reserve 2015</p>
            </center>
            </div>
        </div>    

<?php
   if(isset($_POST['btnBack']))
   {
	   echo "<script> window.close() </script>";
	   exit();
	   }
   if(isset($_POST['btnSave']))
   {
	$jtitle = $gtitle;
	$jcategory = $gcat;
	$jscategory = $gsub;
	$jeducatt = $ged;
	$jexpr = $gyoe;
	$jdescription = $gdesc;
	$jrequirements = $greq;
	$jdate = $cdate;
	$japp = $cneed;
	$refid = $getvariable;
	$today = date('Y-m-d');
	
	mysql_query("INSERT INTO `flss`.`job_order` (`job_ID`, `Title`, `Job_Category`, `Job_sub`, `Job_mined`, `Job_yoe`, `Job_description`, `Job_requirements`, `Job_cdate`, `numapps`, `employer_ID`, `refid`, `date_posted`) 
	VALUES ('', '$jtitle', '$jcategory', '$jscategory', '$jeducatt', '$jexpr', '$jdescription', '$jrequirements', '$jdate', '$japp', '$getid', '$refid' , '$today')") or die(mysql_error());
	
	$pusher = new Pusher(PUSHER_APP_KEY, PUSHER_APP_SECRET, PUSHER_APP_ID);
  	 $pusher->trigger('my-channel', 'job-posted', array( 'job_order_id' => mysql_insert_id()));
 

	   echo "<script> 
	   var mywindow = window.open('Job/joborder.php?refid=$getvariable','popupwindow','left=200,top=50,width=1000,height=600,scrollbars=yes,menu=0,status=0');
	   </script>";
	   exit();
	   }
   
   
   ?>






</body>
</html>
